#include<reg51.h>

unsigned char num[] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xd8, 0x80, 0x90};

unsigned char a = 0;

void delay_ms(unsigned int ms)
{
    unsigned int i, j;
    while (ms--)
    {
        for(i = 0; i < 2; i++){
            for(j = 0; j < 122; j++);
        }
    }
}

void EXINT0() interrupt 0
{
    EX0 = 0;
    delay_ms(20);
    EX0 = 1;
    a++;
    if (a == 10)
    {
        a = 0;
    }
    P1 = num[a];
}

void EXINT1() interrupt 2
{
    EX1 = 0;
    delay_ms(20);
    EX1 = 1;
    if (a == 0)
    {
        a = 10;
    }
    a--;
    P1 = num[a];
}

void main()
{
    P1 = num[0];
    EA = 1;
    EX0 = 1;
    IT0 = 1;
    EX1 = 1;
    IT1 = 1;
    while(1);
}